<template>
  <div>

	<myheader></myheader>


	<br><br>

	<Breadcrumb :datas="datas"></Breadcrumb>

	<section class="featured-block text-center">
		<div class="container">

            <br><br>
		<table border="1">
            <tr>
                <th>商品名称</th>
                <th>商品价格</th>
                <th>商品图片</th>
                <th>商品描述</th>
                <th>商品规格</th>
            </tr>
            <tr v-for="(item,index) in goodslist" :key="index">
                <td><a  :href="'/item?gid='+item.id">{{item.name}}</a></td>
                <td>{{item.price}}</td>
                <td><img :src="'http://localhost:8000/static/upload/'+item.img" height="100px" width="120px"></td>
                <td>{{item.desc}}</td>
                <td>
                    颜色：{{color}}
                    <br>
                    款式：{{season}}
                </td>
            </tr>
        </table>
			
		</div>
	</section>
	
	
	<myfooter></myfooter>
	
    
  </div>
  
</template>


 
<script>

//组件包含
import myheader from './myheader.vue';
import myfooter from './myfooter.vue';


export default {
  data () {
    return {
        //面包屑导航
        datas:[{title:'首页',route:{name:'index'}},{title:'检索页面'}],
        word:'',
        goodslist:[],
        parms:'',
        color:'',
        season:'',
        
    }
  },
  //定义组件
  components:{
	'myheader':myheader,
	'myfooter':myfooter
  },
  mounted:function(){
      //接收参数
      var word = this.$route.query.word;
      this.word = word
      console.log(this.word)
        if(this.word!=''){
       //请求后台接口
		this.axios.get('http://localhost:8000/goodsserach/',{params:{word:this.word}}).then((result) =>{
            this.goodslist = result.data
            if(this.goodslist.length==0){
                        this.$Message("抱歉，没有找到相关物品，请试试其他物品")
                    }
            for (let index = 0; index < result.data.length; index++) {
                    var parms = result.data[index].parms
                    parms = JSON.parse(parms)
			        this.color = parms.color
                    this.season = parms.season
                   
			}
		});
  }
},
  methods:{
	
  },
  //监听属性
  watch: {
      $route(to,from){
          //刷新页面
          this.$router.go(0)
      }
  },
}


</script>
 
<style>



</style>